﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Weapp.Data.Entities;

namespace Weapp.Data.Mappers
{
    public class CharacterMapper : EntityTypeConfiguration<Character>
    {
        public CharacterMapper()
        {
            this.ToTable("Characters");

            this.HasKey(c => c.CharacterId);
            this.Property(c => c.CharacterId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(c => c.CharacterId).IsRequired();

            this.Property(c => c.Name).IsOptional();
            this.Property(c => c.Name).HasMaxLength(50);

            this.Property(c => c.Exp).IsRequired();

            this.Property(c => c.GoodEvilAlignment).IsRequired();

            this.Property(c => c.LawChaosAlignment).IsRequired();

            this.Property(c => c.Deity).HasMaxLength(50);
            this.Property(c => c.Deity).IsOptional();

            this.HasRequired(c => c.SizeCategory).WithMany().Map(s => s.MapKey("SizeCategoryId"));

            this.Property(c => c.Gender).IsRequired();

            this.Property(c => c.Height).IsRequired();

            this.Property(c => c.Weight).IsRequired();
        }
    }
}
